
// 组合使用构造函数和原型模式

function Person(name,age){
    this.name = name;
    this.age = age;
    this.friends = ['Shelly','Court'];
}

Person.prototype.sayName = function(){
    console.log(this.name);
}

var person1 = new Person('lili',19);
var person2 = new Person('lucy',12);
console.log(person1); // { name: 'lili', age: 19, friends: [ 'Shelly', 'Court' ] }
person1.sayName(); // lili
console.log(person1.friends === person2.friends); // fasle
console.log(person1.sayName === person2.sayName); // true